﻿<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" ddwrt:oob="true">
  <xsl:output method="html" indent="no"/>
  <xsl:template match="FieldRef[@FieldType='ListItemOrder']" mode="Number_body">
    <!--Set the thisNode parameter to the current node-->
    <xsl:param name="thisNode" select="." />
    <!--Store the current element-->
    <xsl:variable name="curElement" select="current()" />

    <!--Store the field value we are rendering in a variable for easier access-->
    <xsl:variable name="fldVal">
      <!--We want to return the value of the field that has the same name as the current element being processed-->
      <xsl:value-of select="$thisNode/@*[name()=$curElement/@Name]"/>
    </xsl:variable>
    
    <!--Store the name of the field-->
    <xsl:variable name="fldName">
      <xsl:value-of select="$curElement/@Name"/>
    </xsl:variable>

    <!--Store the ID of the item-->
    <xsl:variable name="itemId">
      <xsl:value-of select="$thisNode/@ID"/>
    </xsl:variable>

    <!--
    Render the field:
    The below <div /> element is hidden - it is used to keep a record of the actual underlying field value
    in order to facilitate the client side interaction
    -->
    <div id="itk_moveval_{$itemId}" style="display:none;"><xsl:value-of select="$fldVal" /></div>
    <img id="itk_moveimg_up_{$itemId}" src="/_layouts/images/ITK/arr_up.png" class="itkmoveimg" alt="move item up" onclick="itk_moveOrder('{$fldName}', {$thisNode/@ID}, 1, $(this).parents('tr:first'), {$dvt_RowCount});return false;" />
    <img id="itk_moveimg_down_{$itemId}" src="/_layouts/images/ITK/arr_down.png" class="itkmoveimg" alt="move item down" onclick="itk_moveOrder('{$fldName}', {$thisNode/@ID}, 0, $(this).parents('tr:first'), {$dvt_RowCount});return false;" />
  </xsl:template>
</xsl:stylesheet>